
// combobox item object
local PANEL = {};

// custom skin hooks
Derma_Hook( PANEL, "Paint", "Paint", "MXComboBoxItem" );
Derma_Hook( PANEL, "ApplySchemeSettings", "Scheme", "MXComboBoxItem" );


/*------------------------------------
	combobox item clicked
------------------------------------*/
function PANEL:DoClick( )
	
	// check if we've been clicked recently, but not this frame (fixes a bug)
	if ( MXCurTime() - self.LastClick <= 0.5 && MXCurTime() != self.LastClick ) then
	
		// call the double-click event
		self:DoDoubleClick();
		
		// set click time as old
		self.LastClick = 0;
		
	else
	
		// store click time
		self.LastClick = MXCurTime();
		
	end
	
end

// define
derma.DefineControl( "MXComboBoxItem", "", PANEL, "DComboBoxItem" );


// combobox object
PANEL = {};

// custom paint hook
Derma_Hook( PANEL, "Paint", "Paint", "MXComboBox" );


/*------------------------------------
	add an item to the combobox
------------------------------------*/
function PANEL:AddItem( text )

	// create the item
	local item = vgui.Create( "MXComboBoxItem", self );
	
	// give um roots!
	item:SetMother( self );
	
	// set the text
	item:SetText( text );
	
	// set click time as old
	item.LastClick = 0;

	// add to panel list
	DPanelList.AddItem( self, item );
	
	// return the item we've created
	return item;

end

// define
derma.DefineControl( "MXComboBox", "", PANEL, "DComboBox" );
